From 1dbe461cf84399554af13da54cc75fd3c98ed581 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Wed, 3 Sep 2008 22:10:43 +0000 Subject: [PATCH] navitel: Add support for Navitel binary tracks (.bin). --- Makefile.in | 4 +- navitel.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++ vecs.c | 8 ++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 navitel.c diff --git a/Makefile.in b/Makefile.in index 816cc598b..27afa2ef0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,7 +59,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \ wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \ ggv_log.o g7towin.o garmin_gpi.o lmx.o random.o xol.o dg-100.o \ navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o vidaone.o \ - igo8.o gopal.o humminbird.o tr7.o gnav_trl.o + igo8.o gopal.o humminbird.o tr7.o gnav_trl.o navitel.o FMTS=@FMTS@ @@ -633,6 +633,8 @@ navilink.o: navilink.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ jeeps/gpsproj.h +navitel.o: navitel.c defs.h config.h queue.h gbtypes.h \ + zlib/zlib.h zlib/zconf.h gbfile.h jeeps/gpsmath.h netstumbler.o: netstumbler.c defs.h config.h queue.h gbtypes.h \ zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h nmea.o: nmea.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ diff --git a/navitel.c b/navitel.c new file mode 100644 index 000000000..806816c96 --- /dev/null +++ b/navitel.c @@ -0,0 +1,111 @@ +/* + + Support for Navitel binary tracks (.bin), + copyright (C) 2008 Olaf.Klein@gpsbabel.org. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include +#include "defs.h" +#include "gbfile.h" +#include "jeeps/gpsmath.h" + +#define MYNAME "navitel" + +static gbfile *fin, *fout; + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ + +static void +navitel_rd_init(const char *fname) +{ + fin = gbfopen(fname, "rb", MYNAME); +} + +static void +navitel_rd_deinit(void) +{ + gbfclose(fin); +} + +static void +navitel_read_track(void) +{ + int points, i; + route_head *trk = NULL; + + points = gbfgetint32(fin); + (void) gbfgetint32(fin); /* unknown */ + + for (i = 0; i < points; i++) { + int lat, lon; + waypoint *wpt; + + lon = gbfgetint32(fin); + lat = gbfgetint32(fin); + + wpt = waypt_new(); + wpt->latitude = GPS_Math_Semi_To_Deg(lat & 0x7FFFFFFF); + wpt->longitude = GPS_Math_Semi_To_Deg(lon); + + if ((lat >> 31) || (trk == NULL)) { + trk = route_head_alloc(); + track_add_head(trk); + } + track_add_wpt(trk, wpt); + } +} + +static void +navitel_wr_init(const char *fname) +{ + fout = gbfopen(fname, "wb", MYNAME); +} + +static void +navitel_wr_deinit(void) +{ + gbfclose(fout); +} + +static void +navitel_write_track(void) +{ +} + +/**************************************************************************/ + +ff_vecs_t navitel_trk_vecs = { + ff_type_file, + { + ff_cap_none /* waypoints */, + ff_cap_read /* tracks */, + ff_cap_none /* routes */ + }, + navitel_rd_init, + navitel_wr_init, + navitel_rd_deinit, + navitel_wr_deinit, + navitel_read_track, + navitel_write_track, + NULL, + NULL, + CET_CHARSET_UTF8, 1 /* Nothing to convert */ +}; +/**************************************************************************/ diff --git a/vecs.c b/vecs.c index 0e1ce1d46..9eb290d0c 100644 --- a/vecs.c +++ b/vecs.c @@ -145,6 +145,7 @@ extern ff_vecs_t humminbird_vecs; extern ff_vecs_t humminbird_ht_vecs; extern ff_vecs_t tr7_vecs; extern ff_vecs_t gnav_trl_vecs; +extern ff_vecs_t navitel_trk_vecs; static vecs_t vec_list[] = { @@ -830,6 +831,13 @@ vecs_t vec_list[] = { "Google Navigator Tracklines (.trl)", "trl" }, + { + &navitel_trk_vecs, + "navitel_trk", + "Navitel binary tracks (.bin)", + "bin" + }, + #endif // MAXIMAL_ENABLED { NULL, -- 2.30.2